<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./index.js"></script>
    <style>
        .kk {
            display: none;
            width: 100px;
            height: 100px;
            color: black;
            font-size: 20px;
        }
        
    </style>
</head>
<body>
    <button>发送请求</button>
    <div class="kk"></div>
    <!-- 我写不出来，照着别人写的，只能解读 -->
    
    <script>
        // 获取摁纽
        const btn = document.querySelector('button')
        // 给摁纽创建点击事件
        btn.addEventListener('click',function() {
            Promise.all([
                myAjax({
                    method:'GET',
                    url:'http://ajax-base-api-t.itheima.net/api/getbooks'
                }),
                myAjax({
                    method:'GET',
                    url:'http://ajax-base-api-t.itheima.net/api/getbooks'
                })
            ]).then(res => {
                document.querySelector('.kk').style.display='block'
                document.querySelector('.kk').innerHTML='请求成功'
            }).catch(err => {
                document.querySelector('.kk').style.display='block'
                document.querySelector('.kk').innerHTML='404'
            })
            }

        )

    </script>
</body>
</html>